//
//  MoreViewController.m
//  网易公开课项目
//
//  Created by 林 艺 on 13-11-10.
//  Copyright (c) 2013年 Marklin. All rights reserved.
//
//  更多视图

#import "MoreViewController.h"
#import "MoreCell.h"

@interface MoreViewController ()

@end

@implementation MoreViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"更多";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.tableView registerNib:[UINib nibWithNibName:@"MoreCell" bundle:nil] forCellReuseIdentifier:@"moreCell"];

    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 2)
    {
        return 1;
    }
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MoreCell *cell = [tableView dequeueReusableCellWithIdentifier:@"moreCell"];
    UIImage *top = [UIImage imageNamed:@"more_top_cell.png"];
    UIImage *middle = [UIImage imageNamed:@"more_mid_cell.png"];
    UIImage *bottom = [UIImage imageNamed:@"more_bottom_cell.png"];
    UIImage *more = [UIImage imageNamed:@"more_cell.png"];
    
    if (indexPath.section == 0)
    {
        if (indexPath.row == 0)
        {
            cell.backImageView.image = top;
            cell.titleLabel.text = @"个人帐号";
        }
        else if(indexPath.row == 1)
        {
            cell.backImageView.image = middle;
            cell.titleLabel.text = @"设置分享帐号";
        }
        else if (indexPath.row == 2)
        {
            cell.backImageView.image = middle;
            cell.titleLabel.text = @"自动推送";
            _autoPost = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 80, 28)];
            
            [cell.switchView addSubview:_autoPost];
            cell.switchView.hidden = NO;            
        }
        else
        {
            cell.backImageView.image = bottom;
            cell.titleLabel.text = @"后台运行时仍下载";
            _downAtBack = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 80, 28)];
            [cell.switchView addSubview:_downAtBack];
            cell.switchView.hidden = NO;
            
        }
    }
    else if (indexPath.section == 1)
    {
        if (indexPath.row == 0)
        {
            cell.backImageView.image = top;
            cell.titleLabel.text = @"意见反馈";
        }
        else if (indexPath.row == 1)
        {
            cell.backImageView.image = middle;
            cell.titleLabel.text = @"关于";
        }
        else if (indexPath.row == 2)
        {
            cell.backImageView.image = middle;
            cell.titleLabel.text = @"评价一下";
        }
        else
        {
            cell.backImageView.image = bottom;
            cell.titleLabel.text = @"检查更新";
        }
        
    }
    else
    {
        cell.backImageView.image = more;
        cell.titleLabel.text = @"应用推荐";
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}


@end
